<template>
    <h1>投资管理</h1>

    <table class="table table-bordered " border="1" >
        <thead>
            <tr>
                <td>投资项目编号</td>
                <td>投资项目名称</td>
                <td>投资项目总金额</td>
                <td>用户已投资金额</td>
                <td>剩余投资金额</td>
                <td>操作</td>
            </tr>
        </thead>
        
        <tbody>
            <tr v-for=" item in info " >
                <td> {{ item.I_Id }} </td>
                <td> {{ item.I_Name }} </td>
                <td> {{ item.I_Budget }} </td>
                <td> {{ item.I_Residue }} </td>
                <td> {{ item.UT_Money }} </td>
                <td>
                    <a href="#" @click="jump(item.I_Id)" >用户赎回明细</a>
                </td>
            </tr>
        </tbody>


    </table>

</template>

<script setup lang="ts">

import {ref,onMounted} from 'vue'
import axios from 'axios'
import {useUserStore} from '../../store/index.ts'
import { useRouter } from 'vue-router';

const router = useRouter();

const userStore = useUserStore();

console.log(userStore.Uid)

const info = ref([{
    I_Id:'',
    I_Name:'',
    I_Budget:'',
    I_Residue:'',
    UT_Money:'',
    UT_Id:''
}])

onMounted(()=>{
    axios({
        method:'get',
        url:'http://localhost:56707/api/Invest/ShowAllUserInvestRedeemInfo',
        params:{
            uid:userStore.Uid,
        }
    })
    .then(res=>{
        console.log(res.data)
        info.value = res.data
    })
    .catch(err=>{
        console.log(err)
    })
})

const jump = (Id:string)=>{
    router.push({
        name:'UserInvestRedeemInfo',
        params:{
            Id:Id
        }
    })
}



</script>
